[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

JS30 Day 17 筆記

JS30 Day 17 筆記

邏輯運算子 及 函式預設值

邏輯運算子 及 函式預設值

[Note] Vite 組態配置(持續更新)

[Note] Vite 組態配置(持續更新)






留言討論